package com.ruoyi.project.sms.service;

import java.time.LocalDateTime;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.db.sms.mapper.SmsAdvertiseMapper;
import com.ruoyi.db.sms.domain.SmsAdvertise;
import com.ruoyi.db.sms.domain.query.SmsAdvertiseQueryVo;

/**
 * 首页广告Service业务层处理
 *
 * @author yfy
 * @date 2020-04-21
 */
@Service
public class SmsAdvertiseService
{
    @Autowired
    private SmsAdvertiseMapper smsAdvertiseMapper;

    /**
     * 查询首页广告
     *
     * @param id 首页广告ID
     * @return 首页广告
     */
    public SmsAdvertise selectSmsAdvertiseById(Long id)
    {
        return smsAdvertiseMapper.selectSmsAdvertiseById(id);
    }

    /**
     * 修改状态
     *
     * @param smsAdvertise 首页广告
     * @return 结果
     */
    public int changeIsEnabledStatus(SmsAdvertise smsAdvertise)
    {
        smsAdvertise.setUpdateTime(LocalDateTime.now());
        return smsAdvertiseMapper.changeIsEnabledStatus(smsAdvertise);
    }


    /**
     * 查询首页广告列表
     *
     * @param smsAdvertiseQueryVo 首页广告查询参数
     * @return 首页广告
     */
    public List<SmsAdvertise> selectSmsAdvertiseList(SmsAdvertiseQueryVo smsAdvertiseQueryVo)
    {
        return smsAdvertiseMapper.selectSmsAdvertiseList(smsAdvertiseQueryVo);
    }

    /**
     * 新增首页广告
     *
     * @param smsAdvertise 首页广告
     * @return 结果
     */
    public int insertSmsAdvertise(SmsAdvertise smsAdvertise)
    {
        smsAdvertise.setAddTime(DateUtils.getNowDate());
        return smsAdvertiseMapper.insertSmsAdvertise(smsAdvertise);
    }

    /**
     * 修改首页广告
     *
     * @param smsAdvertise 首页广告
     * @return 结果
     */
    public int updateSmsAdvertise(SmsAdvertise smsAdvertise)
    {
        smsAdvertise.setUpdateTime(LocalDateTime.now());
        return smsAdvertiseMapper.updateSmsAdvertise(smsAdvertise);
    }

    /**
     * 批量删除首页广告
     *
     * @param ids 需要删除的首页广告ID
     * @return 结果
     */
    public int deleteSmsAdvertiseByIds(Long[] ids)
    {
        return smsAdvertiseMapper.deleteSmsAdvertiseByIds(ids);
    }

    /**
     * 删除首页广告信息
     *
     * @param id 首页广告ID
     * @return 结果
     */
    public int deleteSmsAdvertiseById(Long id)
    {
        return smsAdvertiseMapper.deleteSmsAdvertiseById(id);
    }
}
